package com.lyh.mapper;

import com.lyh.pojo.*;
import com.lyh.pojo.useless.Perm;
import com.lyh.pojo.useless.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserMapper {
    /**
     * 使用标识符来查询用户的角色
     */
    List<Role> queryRolesByUsername(String principal);

    List<Perm> queryPermsByRoleId(int id);

    User queryUserByUsername(String username);

    int registerUser(User user);

    int registerPerson(Person person);

    User queryUserByPhone(String phone);

    /**
     * 下面三个都是查重的方法
     */
    PersonAndUser queryUserDetailByUsername(String username);

    PersonAndUser queryUserByEmail(String email);

    PersonAndUser queryUserByIdentify(String identify);

    /**
     * 查询用户是否已被激活
     */
    byte queryActive(@Param("username") String username);

    /**
     * 激活用户的方法
     */
    void activeUser(@Param("username") String username);

    User queryUserByUserId(@Param("userId") Integer userId);
}
